import {
  ObjectStack,
} from './index';

/**
 * @description Transfer dicimal int to other carry system
 * @param decNumber dicimal int 
 * @param base other carry system
 */
export function transDecimalOtherCarryInt(decNumber: number, base: number) {
  const remStack = new ObjectStack();
  const digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';

  let number = decNumber;
  let baseStr = '';

  if (base < 2 || base > 36) {
    return '';
  }

  while (number > 0) {
    remStack.push(number % base);
    number = Math.floor(number / base);
  }


  while (!remStack.isEmpty()) {
    baseStr += digits[remStack.pop()];
  }

  return baseStr;
}
